import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Log {
    private LocalDateTime time;
    private String type; // 操作类型
    private String operator; // 操作人

    public Log(String type, String operator) {
        this.time = LocalDateTime.now();
        this.type = type;
        this.operator = operator;
    }

    // 保存日志到控制台（实际项目可改为写入文件）
    public void saveLog() {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String log = String.format("[%s] 操作人: %s, 操作: %s",
                time.format(formatter), operator, type);
        System.out.println("日志记录: " + log);
    }
}
    